package logger;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.Observable;
import java.util.Observer;

public class Logger implements Observer {

    private BufferedWriter bufferedWriter = null;
    
    public Logger(){   
        try {
            bufferedWriter = new BufferedWriter(new FileWriter("log.txt"));
        } catch (Exception ex) {
            System.out.println(ex.getMessage());   
        }           
    }
    
    @Override
    public void update(Observable o, Object arg) {
        try {
            bufferedWriter.write((String)arg);
            bufferedWriter.newLine();
            bufferedWriter.flush();
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
    }
   
}
